/**
 * @file      ac_tlm_rot.cpp
 * @author    Luisa Madeira Cardoso
 *
 * @version   0.1
 * @date      Sun, 29 Apr 2012 11:03:46 -0200
 *
 * @brief     Implements a ac_tlm router.
 *
 * @attention Copyright (C) 2002-2005 --- The ArchC Team
 *
 *   This library is free software; you can redistribute it and/or
 *   modify it under the terms of the GNU Lesser General Public
 *   License as published by the Free Software Foundation; either
 *   version 2.1 of the License, or (at your option) any later version.
 *
 *   This library is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *   Lesser General Public License for more details.
 *
 *
 */

//////////////////////////////////////////////////////////////////////////////
// Standard includes
// SystemC includes
// ArchC includes

#include "ac_tlm_rot.h"

//////////////////////////////////////////////////////////////////////////////

/// Namespace to isolate memory from ArchC
using user::ac_tlm_rot;

/// Constructor
ac_tlm_rot::ac_tlm_rot( sc_module_name module_name) :
  sc_module( module_name ),
  target_export("iport1"),
  mem_port("mem_port", 5242880U),
  mul_port("mul_port", 24U),
  add_port("add_port", 24U),
  exp_port("exp_port", 24U),
  div_port("div_port", 24U),
  srt_port("srt_port", 18U)
  //lck_port("lck_port", 8U)

{
  target_export( *this );
}

/// Destructor
ac_tlm_rot::~ac_tlm_rot() {

}

// Change endianess
uint32_t ac_tlm_rot::changeEndianess(uint32_t data) {
    union word_t {
    uint32_t b;
    char c[4];
  } ;

  word_t word_request;
  word_t word_new_request;

  word_request.b = data;

  for(int i = 0; i < 4; i++) {
    word_new_request.c[i] = word_request.c[3-i];
  }
  return word_new_request.b;
}
